package com.timber.util;

import java.sql.*;

/**
 *	implementation of the SLDataObjectAdaptor class
 *	used as default by SLDataMgr to
 *	load Code / Description pairs from the database.
 *	Description, column 2, is optional
 */
public class SLDataStringPair extends SLDataObjectAdaptor
{
    private String itemCode;
    private String itemDesc;

    public SLDataStringPair()
    {}

    public boolean load( ResultSet rs ) throws SQLException
    {
	itemCode = rs.getString( 1 );
	try { itemDesc = rs.getString( 2 ); } catch( Exception ex ){}
	return true;
    }

    public Object hashKey() { return itemCode; }
    public String listString() { return itemCode; }
    public String toString()
    {
	return itemCode + ( itemDesc == null ? "" : "  " + itemDesc );
    }

    public String getCode() { return itemCode; }
    public String getDescription() { return itemDesc; }


}
